﻿@model IEnumerable<FShare.ViewModels.UsersViewModel>

@{
    ViewBag.Title = "Users";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Registered users</h2>
<table class="admin-table">
    <tr>
        <td class="admin-left-sidebar">
            @Html.Partial(FShare.Helpers.Constants.ADMIN_LEFT_NAVIGATION_MENU_NAME)
        </td>
        <td class="admin-main-content">
            <table>
                <colgroup>
                    <col />
                    <col />
                    <col />
                    <col />
                    <col />
                    <col />
                </colgroup>
                <thead>
                    <tr>
                        <th>Username</th>
                        <th>E-Mail</th>
                        <th>Last Activity</th>
                        <th>Registered at</th>
                        <th>Uploaded files</th>
                        <th>Role</th>
                    </tr>
                </thead>
                <tbody>
                @foreach (var user in Model)
                {
                    <tr>
                        <td>@user.UserName</td>
                        <td>@user.EMail</td>
                        <td>@user.LastActivity</td>
                        <td>@user.DateOfRegistration.ToShortDateString()</td>
                        <td>@user.UploadedFilesCount</td>
                        <td>
                        @if (user.IsAdministrator)
                        {
                            <span>@Html.ActionLink("Remove admin", "ChangeRole", new { id = user.UserName }, null)</span>
                        }
                        else
                        {
                            <span>@Html.ActionLink("Make admin", "ChangeRole", new { id = user.UserName }, null)</span>
                        }
                        </td>
                    </tr>
                }
                </tbody>
            </table>
        </td>
    </tr>
</table>

